import { STAFF_SETTING_VAL_TYPES } from '@/enums/staffSetting';
import type { CreateFormItemsOption } from '@ykst/components';
import { requiredRuleFactory } from '@ykst/shared';
import type { Rule } from 'ant-design-vue/es/form';

export const formOption: CreateFormItemsOption[] = [
  {
    type: 'input',
    name: 'title',
    label: '字段名称',
  },
  {
    type: 'select',
    name: 'val_type',
    label: '字段类型',
    nodeProps: {
      options: STAFF_SETTING_VAL_TYPES,
    },
  },
  {
    type: 'switch',
    name: 'status',
    label: '是否启用',
    nodeProps: {
      checkedChildren: '启用',
      unCheckedChildren: '停用',
    },
    nodeAttrs: {
      style: 'width:auto',
    },
  },
  {
    type: 'switch',
    name: 'is_required',
    label: '是否必填',
    nodeProps: {
      checkedChildren: '是',
      unCheckedChildren: '否',
    },
    nodeAttrs: {
      style: 'width:auto',
    },
  },
];

export const formRules: Record<string, Rule[]> = {
  title: [requiredRuleFactory('请填写设备类型')],
  desc: [requiredRuleFactory('请填写字段选项')],
};
